package com.giao.mapper;

import com.giao.vo.OutProductVo;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface OutProductVOMapper {

    @Results({
            @Result(column = "CUSTOM_NAME", property = "customName"),
            @Result(column = "CONTRACT_NO", property = "contractNo"),
            @Result(column = "PRODUCT_NO", property = "productNo"),
            @Result(column = "CNUMBER", property = "cnumber"),
            @Result(column = "FACTORY", property = "factoryName"),
            @Result(column = "DELIVERY_PERIOD", property = "deliveryPeriod"),
            @Result(column = "SHIP_TIME", property = "shipTime")
    })
    //带条件查询，条件可以为null，既没有条件，返回list对象集合
    @Select("select\n" +
            "    c.CUSTOM_NAME,c.CONTRACT_NO,c.DELIVERY_PERIOD ,c.SHIP_TIME,\n" +
            "    cp.PRODUCT_NO,cp.CNUMBER as cnumber,cp.FACTORY\n" +
            "  from\n" +
            "  (select CONTRACT_ID,CUSTOM_NAME,CONTRACT_NO,DELIVERY_PERIOD,SHIP_TIME from CONTRACT_C) c\n" +
            "  left join\n" +
            "  (select CONTRACT_ID,PRODUCT_NO,CNUMBER,PACKING_UNIT,FACTORY from CONTRACT_PRODUCT_C) cp\n" +
            "  on c.CONTRACT_ID=cp.CONTRACT_ID\n" +
            "\n" +
            "  where c.SHIP_TIME  LIKE CONCAT(CONCAT('%', #{shipTime}), '%')")
    public List<OutProductVo> find(String inputDate);

}
